package com.weixing.mall.provider.controller.cms;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.dto.cms.SpareLinkAddrChgEnableDto;
import com.weixing.mall.provider.model.dto.cms.SpareLinkAddrDto;
import com.weixing.mall.provider.service.ISpareLinkAddrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: kfc
 * @Description: <br/>
 * Date:Create in 2019/9/9 12:00
 * @Modified By:
 */
@RestController
@RequestMapping("linkAddr")
@Api(value = "备用链接地址API", tags = "备用链接地址")
public class SpareLinkAddrController extends BaseController {
    @Autowired
    private ISpareLinkAddrService spareLinkAddrService;

    @ApiOperation(value = "加载备用链接列表")
    @GetMapping("")
    public Result list() {
        return ResultUtil.success(spareLinkAddrService.selectList(initMpPage()));
    }

    @ApiOperation(value = "删除")
    @GetMapping("del/{id}")
    public Result del(@PathVariable long id) {
        return spareLinkAddrService.removeById(id) ? ResultUtil.success() : ResultUtil.error();
    }

    @ApiOperation(value = "更改可用状态")
    @PostMapping("changeEnable")
    public Result changeEnable(SpareLinkAddrChgEnableDto dto) {
        spareLinkAddrService.changeEnable(dto);
        return ResultUtil.success();
    }

    @ApiOperation(value = "保存")
    @PostMapping("save")
    public Result save(SpareLinkAddrDto dto) {
        spareLinkAddrService.save(dto);
        return ResultUtil.success();
    }

}
